home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / Tools / PRINT_IT.207 / PRINT_IT.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-05-30  |  26.5 KB  |  1,047 lines

  1. '··············································································
  2. ' Print IT v2.07  © 1996,97 Cadenza Software - Written by Matthew Bacon
  3. ' HiSoft BASIC GEM Toolkit - Written by Dave Nutkins and Ofir Gal
  4. ' © Copyright HiSoft 1991-3
  5. '··············································································
  6. ' Include GEMTOOL.T
  7.  
  8. '$option q80,y
  9. LIBRARY "bios"
  10. DIM SHARED OPTIONS$(51),CCODES$(51),BOPTIONS$(0),BCCODES$(0)
  11. '$INCLUDE E:\cadenza.97\PRINT_IT\PRINT_IT.206\PRINT_IT.BH
  12.  
  13. '··············································································
  14.  
  15. ' File selector handler - returns a new pathname
  16. ' the global variables fspath$ and fsname$ keep the appropriate
  17. ' GEM items.
  18. SUB FileSelect$(fspath$,fsname$,fsmessage$)
  19. SHARED fspath$,fsname$,fsmessage$,FileSelect$
  20. STATIC ok,i,ch
  21. IF fspath$="" THEN CALL InitFileSelector
  22. IF aes_version<&H130 THEN
  23.     fsel_input fspath$,fsname$,ok
  24. ELSE 
  25.     fsel_exinput fspath$,fsname$,ok,fsmessage$
  26. END IF
  27. IF ok THEN
  28.     i=LEN(fspath$)
  29.     DO
  30.         ch=ASC(MID$(fspath$,i,1))
  31.         IF ch="\"% OR ch=":"% THEN EXIT LOOP
  32.         IF i=1 THEN EXIT LOOP
  33.         DECR i
  34.     LOOP 
  35.     FileSelect$=LEFT$(fspath$,i)+fsname$
  36. ELSE
  37.     FileSelect$=""
  38. END IF
  39. END SUB
  40.  
  41. ' initialise the file selector
  42. SUB    InitFileSelector
  43. SHARED fspath$,fsname$
  44. fspath$=CURDIR$+"\*.*"
  45. fsname$=""
  46. END SUB
  47.  
  48. '··············································································
  49.  
  50. ' set a tedinfo record
  51. SUB Sette_ptext_update(BYVAL object,BYVAL newted$,handle)
  52. SHARED edit_handle,main_handle
  53. STATIC t&,chars,i,oldtree&
  54.  
  55. oldtree&=tree&
  56. IF handle=1 THEN SelectTree FORM_EDIT
  57. IF handle=2 THEN SelectTree FORM_MAIN
  58.  
  59. t&=Getob_spec&(object)
  60. chars=MIN(PEEKW(t&+te_txtlen)-1,LEN(newted$))        '-1 for the null
  61. t&=PEEKL(t&+te_ptext)
  62. FOR i=1 TO chars
  63.     POKEB t&,ASC(MID$(newted$,i,1))
  64.     INCR t&
  65. NEXT i
  66. POKEB t&,0                                    'must end in null
  67. tree&=oldtree&
  68. END SUB
  69.  
  70. '··············································································
  71.  
  72. SUB INITIALISE
  73. SHARED Output$,menutree&,total_edititems,total_mainitems,total_batchitems
  74. SHARED top_edititem,top_mainitem,top_batchitem,edit_handle,main_handle
  75. SHARED fspath$,fsname$,about_handle,edit_handle,main_handle,Delete_status
  76. STATIC i
  77.  
  78. CALL menu_icheck (menutree&,MENU_DIRECT,1)
  79. Output$="Direct"
  80. total_edititems=50
  81. total_mainitems=50
  82. total_batchitems=0
  83. top_edititem=0
  84. top_mainitem=0
  85. top_batchitem=0
  86. Delete_status=-1
  87.  
  88. FOR i=O1 TO C12
  89.     Sette_ptext_update i,"",1
  90. NEXT
  91. FOR i=SO1 TO SO12
  92.     Sette_ptext_update i,"",2
  93. NEXT
  94. FOR i=B1 TO B10
  95.     Sette_ptext_update i,"",2
  96. NEXT
  97.  
  98. FOR i=0 TO 50
  99.     OPTIONS$(i)=""
  100.     CCODES$(i)=""
  101. NEXT
  102.  
  103. fspath$=CURDIR$+"\*.DRV"
  104. fsname$="PRINTER.DRV"
  105. CALL LOAD_PRINTERDRIVER(CURDIR$+"\PRINTER.DRV")
  106. CALL DISPLAY_PRINTERDRIVER2
  107. edit_handle=openformwindow(" Edit : Print IT ",&h0B,FORM_EDIT,O1,EDIT_QUIT,VARPTRS(close_editdialog))
  108. CALL SCROLL2(total_edititems,12,E_SLIDER,E_BACKGROUND)
  109. main_handle=openformwindow(" Print IT ",&h0B,FORM_MAIN,0,MAIN_QUIT,VARPTRS(close_maindialog))
  110. CALL SCROLL2(total_mainitems,12,S_SLIDER,S_BACKGROUND)
  111. CALL SCROLL2(total_batchitems,10,B_SLIDER,B_BACKGROUND)
  112. about_handle=openformwindow(" About... ",&h0B,FORM_ABOUT,0,ABOUT_OK,VARPTRS(close_aboutdialog))
  113. END SUB
  114.  
  115. '··············································································
  116.  
  117. SUB processusermenus(VAL topwin,VAL item,VAL title)
  118. SHARED commonclose,commonobj,menutree&
  119. SHARED about_handle,edit_handle,Output$,total_edititems,total_batchitems
  120. SHARED top_batchitem,delete_status
  121. STATIC test$,i,button
  122.  
  123. commonclose=0                                        
  124. IF Delete_status=0 THEN EXIT SUB
  125.  
  126. SELECT CASE item
  127.     CASE MENU_ABOUT
  128.         IF about_handle THEN
  129.             TopAWindow about_handle
  130.         ELSE
  131.             about_handle=openformwindow(" About... ",9,FORM_ABOUT,0,ABOUT_OK,VARPTRS(close_aboutdialog))
  132.         END IF
  133.     CASE MENU_LOADPD
  134.         CALL LOAD_PRINTERDRIVER("")
  135.         CALL DISPLAY_PRINTERDRIVER
  136.     CASE MENU_SAVEPD
  137.         CALL SAVE_PRINTERDRIVER
  138.     CASE MENU_NEWBATCH
  139.         button=form_alert(2,"[2][  Do you really want to create |  a new batch file ? ][ Continue | Cancel ]")
  140.         SELECT CASE button
  141.         CASE 1
  142.             total_batchitems=0
  143.             top_batchitem=0
  144.             REDIM PRESERVE BOPTIONS$(0)
  145.             REDIM PRESERVE BCCODES$(0)
  146.             CALL DISPLAY_BATCH
  147.         END SELECT
  148.     CASE MENU_LOADBATCH
  149.         CALL LOAD_BATCH
  150.         CALL DISPLAY_BATCH
  151.     CASE MENU_SAVEBATCH
  152.         CALL SAVE_BATCH
  153.     CASE MENU_SENDBATCH
  154.         CALL SEND_BATCH(-1)
  155.     CASE=MENU_QUIT
  156.         CALL QUIT_ME
  157.     CASE MENU_DIRECT
  158.         CALL menu_icheck (Menutree&,MENU_DIRECT,1)
  159.         CALL menu_icheck (Menutree&,MENU_TOBATCH,0)
  160.         Output$="Direct"
  161.     CASE MENU_TOBATCH
  162.         CALL menu_icheck (Menutree&,MENU_DIRECT,0)
  163.         CALL menu_icheck (Menutree&,MENU_TOBATCH,1)
  164.         Output$="To Batch"
  165.     CASE MENU_SENDTEST
  166.         CALL Printer_Status(-1)
  167.         test$=""
  168.         FOR i=65 TO 90
  169.             test$=test$+CHR$(i)
  170.         NEXT
  171.         FOR i=97 TO 122
  172.             test$=test$+CHR$(i)
  173.         NEXT
  174.         FOR i=49 TO 57
  175.             test$=test$+CHR$(i)
  176.         NEXT
  177.         LPRINT test$+"0"
  178. END SELECT
  179. END SUB
  180.  
  181. '··············································································
  182.  
  183. SUB close_aboutdialog
  184. SHARED commonclose,commonobj,about_handle
  185.  
  186. commonclose=0                                        
  187. SELECT CASE commonobj
  188.     CASE=ABOUT_OK
  189.         commonclose=-1
  190.         about_handle=0
  191. END SELECT
  192. END SUB
  193.  
  194. '··············································································
  195.  
  196. SUB close_editdialog
  197. SHARED commonclose,commonobj,edit_handle,Output$
  198. SHARED total_edititems,top_edititem,delete_status
  199.  
  200. commonclose=0                                        
  201. IF Delete_status=0 THEN 
  202.     Setob_state commonobj,0
  203.     Object_Redraw edit_handle,commonobj
  204.     EXIT SUB
  205. END IF
  206.  
  207. SELECT CASE commonobj
  208.     CASE EDIT_LOAD
  209.         CALL LOAD_PRINTERDRIVER("")
  210.         CALL DISPLAY_PRINTERDRIVER
  211.     CASE EDIT_SAVE
  212.         CALL SAVE_PRINTERDRIVER
  213.     CASE=E_ARROWUP
  214.         DECR top_edititem
  215.         IF top_edititem<0 THEN
  216.             top_edititem=0
  217.             DO
  218.             LOOP UNTIL MOUSE(2)=0
  219.             EXIT SELECT
  220.         END IF
  221.         CALL UPDATE_EDITDISPLAY
  222.     CASE=E_ARROWDOWN
  223.         INCR top_edititem
  224.         IF top_edititem>total_edititems-12 THEN
  225.             top_edititem=total_edititems-12
  226.             DO
  227.             LOOP UNTIL MOUSE(2)=0
  228.             EXIT SELECT
  229.         END IF
  230.         CALL UPDATE_EDITDISPLAY
  231.     CASE=EDIT_QUIT
  232.         CALL QUIT_ME
  233. END SELECT
  234. Setob_state commonobj,0:Object_Redraw edit_handle,commonobj
  235. END SUB
  236.  
  237. '··············································································
  238.  
  239. SUB close_maindialog
  240. SHARED commonclose,commonobj,main_handle,total_mainitems,total_batchitems
  241. SHARED top_mainitem,top_batchitem,delete_status
  242. STATIC w,h,startx,starty,inx,inh,inw,iny,outx,outy,object
  243. STATIC found_over,button,temp_option$,temp_ccode$
  244.  
  245. commonclose=0                                        
  246. IF Delete_status=0 THEN 
  247.     SELECT CASE commonobj
  248.         CASE B1 TO B10
  249.         CASE=B_DELETE
  250.  
  251.         CASE ELSE
  252.             Setob_state commonobj,0:Object_Redraw main_handle,commonobj
  253.             EXIT SUB
  254.     END SELECT
  255. END IF
  256.  
  257. SELECT CASE commonobj
  258.     CASE SO1 TO SO12
  259.         CALL Send_to_Output((commonobj-9)+top_mainitem,commonobj)
  260.     CASE=S_ARROWUP
  261.         DECR top_mainitem
  262.         IF top_mainitem<0 THEN 
  263.             top_mainitem=0
  264.             DO
  265.             LOOP UNTIL MOUSE(2)=0
  266.             EXIT SELECT
  267.         END IF
  268.         CALL UPDATE_MAINDISPLAY
  269.     CASE=S_ARROWDOWN
  270.         INCR top_mainitem
  271.         IF top_mainitem>total_mainitems-12 THEN 
  272.             top_mainitem=total_mainitems-12
  273.             DO
  274.             LOOP UNTIL MOUSE(2)=0
  275.             EXIT SELECT
  276.         END IF
  277.         CALL UPDATE_MAINDISPLAY
  278.  
  279.     CASE=B_NEW
  280.         button=form_alert(2,"[2][  Do you really want to create |  a new batch file ? ][ Continue | Cancel ]")
  281.         SELECT CASE button
  282.         CASE 1
  283.             total_batchitems=0
  284.             top_batchitem=0
  285.             REDIM PRESERVE BOPTIONS$(0)
  286.             REDIM PRESERVE BCCODES$(0)
  287.             CALL DISPLAY_BATCH
  288.         END SELECT
  289.     CASE=B_LOAD
  290.         CALL LOAD_BATCH
  291.         CALL DISPLAY_BATCH
  292.     CASE=B_SAVE
  293.         CALL SAVE_BATCH
  294.     CASE=B_DELETE
  295.         IF Delete_status=-1 THEN 
  296.             Delete_status=0
  297.             EXIT SUB
  298.         ELSE
  299.             Delete_status=-1
  300.         END IF
  301.     CASE=B_SEND
  302.         CALL SEND_BATCH(commonobj)
  303.     CASE B1 TO B10
  304.         IF Gette_ptext$(commonobj)="" THEN EXIT SELECT
  305.         IF Delete_status=0 THEN CALL Delete_Batch((commonobj-27)+top_batchitem):EXIT SELECT
  306.         junk=objc_offset(tree&,commonobj,startx,starty)
  307.         w=Getob_width(commonobj)
  308.         h=Getob_height(commonobj)
  309.         junk=objc_offset(tree&,b_backdrop,inx,iny)
  310.         inw=Getob_width(b_backdrop)
  311.         inh=Getob_height(b_backdrop)
  312.         CALL graf_dragbox(w,h,startx,starty,inx,iny,inw,inh,outx,outy)
  313.         found_over=objc_find(tree&,object,10,outx,outy+(h/2))
  314.         IF NOT found_over=commonobj THEN
  315.         IF Gette_ptext$(found_over)="" THEN EXIT SELECT
  316.         SELECT CASE found_over
  317.             CASE B1 TO B10
  318.                 temp_option$=BOPTIONS$((commonobj-27)+top_batchitem)
  319.                 temp_ccode$=BCCODES$((commonobj-27)+top_batchitem)
  320.                 BOPTIONS$((commonobj-27)+top_batchitem)=BOPTIONS$((found_over-27)+top_batchitem)
  321.                 BCCODES$((commonobj-27)+top_batchitem)=BCCODES$((found_over-27)+top_batchitem)
  322.                 BOPTIONS$((found_over-27)+top_batchitem)=temp_option$
  323.                 BCCODES$((found_over-27)+top_batchitem)=temp_ccode$
  324.                 CALL UPDATE_BATCHDISPLAY
  325.         END SELECT
  326.         END IF
  327.     CASE=B_ARROWUP
  328.         DECR top_batchitem
  329.         IF top_batchitem<0 THEN 
  330.             top_batchitem=0
  331.             DO
  332.             LOOP UNTIL MOUSE(2)=0
  333.             EXIT SELECT
  334.         END IF
  335.         CALL UPDATE_BATCHDISPLAY
  336.     CASE=B_ARROWDOWN
  337.         INCR top_batchitem
  338.         IF top_batchitem>total_batchitems-10 THEN 
  339.             top_batchitem=total_batchitems-10
  340.             IF top_batchitem<0 THEN top_batchitem=0
  341.             DO
  342.             LOOP UNTIL MOUSE(2)=0
  343.             EXIT SELECT
  344.         END IF
  345.         CALL UPDATE_BATCHDISPLAY
  346.     CASE=MAIN_QUIT
  347.         CALL QUIT_ME
  348. END SELECT
  349. Setob_state commonobj,0:Object_Redraw main_handle,commonobj
  350. END SUB
  351.  
  352. '··············································································
  353.  
  354. SUB SCROLL(total_items,display_items,top_item,object,background,handle)
  355. STATIC i!,height!,y_position!,x,y,w,h
  356.  
  357. IF total_items=<display_items THEN
  358.     Setob_y object,0
  359.     Setob_height object,Getob_Height(background)
  360. ELSE
  361.     i!=Getob_Height(background)/total_items
  362.     height!=i!*display_items
  363.     y_position!=i!*top_item
  364.     Setob_y object,y_position!
  365.     Setob_height object,height!
  366. END IF
  367. w=Getob_width(background)
  368. h=Getob_height(background)
  369. junk=objc_offset(tree&,background,x,y)
  370. junk=objc_draw(tree&,background,10,x,y,w,h)
  371. END SUB
  372.  
  373. '··············································································
  374.  
  375. SUB SCROLL2(total_items,display_items,object,background)
  376. STATIC i!,height!
  377.  
  378. IF total_items=<display_items THEN
  379.     Setob_y object,0
  380.     Setob_height object,Getob_Height(background)
  381. ELSE
  382.     i!=Getob_Height(background)/total_items
  383.     height!=i!*display_items
  384.     Setob_y object,0
  385.     Setob_height object,height!
  386. END IF
  387. END SUB
  388.  
  389. '··············································································
  390.  
  391. ' Load a text file from disk into memory
  392. SUB LOAD_PRINTERDRIVER(FileSelected$)
  393. SHARED total_edititems,total_mainitems,top_edititem,top_mainitem
  394. SHARED FileSelect$,fsname$,fspath$,FileSelected$
  395. STATIC i,check,current_option$
  396.  
  397. ' Call FileSelector
  398. IF FileSelected$="" THEN 
  399.     MOUSE 2
  400.     CALL FileSelect$(CURDIR$+"\*.DRV",fsname$,"Choose a Driver...")
  401.     MOUSE 0
  402. ELSE
  403.     FileSelect$=FileSelected$
  404. END IF
  405.  
  406. MOUSE 2
  407. IF fsname$<>"" THEN
  408.     IF FileSelect$<>"" THEN
  409.     IF FEXISTS(FileSelect$) THEN
  410.         OPEN FileSelect$ FOR INPUT AS #1
  411.         i=0
  412.         check=-1
  413.         DO
  414.             INPUT #1,OPTIONS$(i),CCODES$(i)
  415.  
  416.             IF check=-1 THEN
  417.                 IF OPTIONS$(0)="·Print IT Driver·" THEN
  418.                     IF NOT CCODES$(0)="·© 1996 Cadenza Software - Written by Matthew Bacon·" THEN
  419.                         junk=form_alert(1,"[1][  This is not a valid |  Printer Driver. | ][ Abort ]")
  420.                         FOR i=0 TO 50
  421.                             OPTIONS$(i)=""
  422.                             CCODES$(i)=""
  423.                         NEXT
  424.                         EXIT LOOP
  425.                     END IF
  426.                 ELSE
  427.                     junk=form_alert(1,"[1][  This is not a valid |  Printer Driver. | ][ Abort ]")
  428.                     FOR i=0 TO 50
  429.                         OPTIONS$(i)=""
  430.                         CCODES$(i)=""
  431.                     NEXT
  432.                     EXIT LOOP
  433.                 END IF
  434.                 check=0
  435.             END IF
  436.  
  437.             IF OPTIONS$(i)="" AND CCODES$(i)="" THEN 
  438.  
  439.             ELSE
  440.             current_option$=OPTIONS$(i)
  441.             SELECT CASE current_option$
  442.                 CASE="·Start·"
  443.                     i=0
  444.                 CASE="·End·"
  445.                     OPTIONS$(i)=""
  446.                     CCODES$(i)=""
  447.                     EXIT LOOP
  448.                 CASE ELSE
  449.                     INCR i
  450.             END SELECT
  451.             END IF
  452.         LOOP UNTIL EOF(1)
  453.         CLOSE #1
  454.         top_edititem=0
  455.         top_mainitem=0
  456.     ELSE
  457.         ' If the filename passed does not exists then display error
  458.         IF FileSelected$<>"" THEN
  459.             junk=form_alert(1,"[1][  Error while loading Driver |  file into memory. | ][ Abort ]")
  460.             FileSelected$=""
  461.         END IF
  462.     END IF
  463.     END IF
  464. END IF
  465. MOUSE 0
  466. END SUB
  467.  
  468. '··············································································
  469.  
  470. ' Save a text file from memory to disk
  471. SUB SAVE_PRINTERDRIVER
  472. SHARED total_edititems
  473. SHARED FileSelect$,fsname$,fspath$
  474. STATIC i
  475.  
  476. ' Call FileSelector
  477. MOUSE 2
  478. CALL FileSelect$(CURDIR$+"\*.DRV",fsname$,"Save Driver...")
  479. MOUSE 0
  480.  
  481. MOUSE 2
  482. IF fsname$<>"" THEN
  483.     IF FileSelect$<>"" THEN
  484.     ' Open file to channel 1
  485.     OPEN FileSelect$ FOR OUTPUT AS #1
  486.     WRITE #1,"·Print IT Driver·","·© 1996 Cadenza Software - Written by Matthew Bacon·"
  487.     WRITE #1,"",""
  488.     WRITE #1,"·Start·",""
  489.  
  490.     FOR i=0 TO total_edititems
  491.         WRITE #1,OPTIONS$(i),CCODES$(i)
  492.     NEXT
  493.  
  494.     WRITE #1,"·End·",""
  495.     CLOSE #1
  496.     junk=form_alert(1,"[0][  Printer Driver has been |  saved to disk. | ][ OK ]")
  497.     END IF
  498. END IF
  499. MOUSE 0
  500. END SUB
  501.  
  502. '··············································································
  503.  
  504. SUB GET_DATA
  505. SHARED top_edititem,top_mainitem,main_handle
  506. STATIC i,k,oldtree&
  507.  
  508. oldtree&=tree&
  509. SelectTree FORM_EDIT
  510. k=top_edititem
  511. OPTIONS$(k+0)=Gette_ptext$(O1)
  512. OPTIONS$(k+1)=Gette_ptext$(O2)
  513. OPTIONS$(k+2)=Gette_ptext$(O3)
  514. OPTIONS$(k+3)=Gette_ptext$(O4)
  515. OPTIONS$(k+4)=Gette_ptext$(O5)
  516. OPTIONS$(k+5)=Gette_ptext$(O6)
  517. OPTIONS$(k+6)=Gette_ptext$(O7)
  518. OPTIONS$(k+7)=Gette_ptext$(O8)
  519. OPTIONS$(k+8)=Gette_ptext$(O9)
  520. OPTIONS$(k+9)=Gette_ptext$(O10)
  521. OPTIONS$(k+10)=Gette_ptext$(O11)
  522. OPTIONS$(k+11)=Gette_ptext$(O12)
  523.  
  524. CCODES$(k+0)=Gette_ptext$(C1)
  525. CCODES$(k+1)=Gette_ptext$(C2)
  526. CCODES$(k+2)=Gette_ptext$(C3)
  527. CCODES$(k+3)=Gette_ptext$(C4)
  528. CCODES$(k+4)=Gette_ptext$(C5)
  529. CCODES$(k+5)=Gette_ptext$(C6)
  530. CCODES$(k+6)=Gette_ptext$(C7)
  531. CCODES$(k+7)=Gette_ptext$(C8)
  532. CCODES$(k+8)=Gette_ptext$(C9)
  533. CCODES$(k+9)=Gette_ptext$(C10)
  534. CCODES$(k+10)=Gette_ptext$(C11)
  535. CCODES$(k+11)=Gette_ptext$(C12)
  536.  
  537. SelectTree FORM_MAIN
  538. k=top_mainitem
  539. FOR i=SO1 TO SO12
  540.     Sette_ptext_update i,OPTIONS$(k),2
  541.     INCR k
  542. NEXT
  543. Object_Redraw main_handle,S_BACKDROP
  544. tree&=oldtree&
  545. END SUB
  546.  
  547. '··············································································
  548.  
  549. SUB DISPLAY_PRINTERDRIVER
  550. SHARED total_edititems,total_mainitems
  551. SHARED edit_handle,main_handle
  552. STATIC i,k,oldtree&
  553.  
  554. oldtree&=tree&
  555. SelectTree FORM_EDIT
  556. k=0
  557. Sette_ptext_update O1,OPTIONS$(k+0),1
  558. Sette_ptext_update O2,OPTIONS$(k+1),1
  559. Sette_ptext_update O3,OPTIONS$(k+2),1
  560. Sette_ptext_update O4,OPTIONS$(k+3),1
  561. Sette_ptext_update O5,OPTIONS$(k+4),1
  562. Sette_ptext_update O6,OPTIONS$(k+5),1
  563. Sette_ptext_update O7,OPTIONS$(k+6),1
  564. Sette_ptext_update O8,OPTIONS$(k+7),1
  565. Sette_ptext_update O9,OPTIONS$(k+8),1
  566. Sette_ptext_update O10,OPTIONS$(k+9),1
  567. Sette_ptext_update O11,OPTIONS$(k+10),1
  568. Sette_ptext_update O12,OPTIONS$(k+11),1
  569.  
  570. Sette_ptext_update C1,CCODES$(k+0),1
  571. Sette_ptext_update C2,CCODES$(k+1),1
  572. Sette_ptext_update C3,CCODES$(k+2),1
  573. Sette_ptext_update C4,CCODES$(k+3),1
  574. Sette_ptext_update C5,CCODES$(k+4),1
  575. Sette_ptext_update C6,CCODES$(k+5),1
  576. Sette_ptext_update C7,CCODES$(k+6),1
  577. Sette_ptext_update C8,CCODES$(k+7),1
  578. Sette_ptext_update C9,CCODES$(k+8),1
  579. Sette_ptext_update C10,CCODES$(k+9),1
  580. Sette_ptext_update C11,CCODES$(k+10),1
  581. Sette_ptext_update C12,CCODES$(k+11),1
  582. Object_Redraw edit_handle,E_BACKDROP
  583. CALL SCROLL2(total_edititems,12,E_SLIDER,E_BACKGROUND)
  584. Object_Redraw edit_handle,e_background
  585.  
  586. SelectTree FORM_MAIN
  587. k=0
  588. FOR i=SO1 TO SO12
  589.     Sette_ptext_update i,OPTIONS$(k),2
  590.     INCR k
  591. NEXT
  592. Object_Redraw main_handle,S_BACKDROP
  593. CALL SCROLL2(total_mainitems,12,S_SLIDER,S_BACKGROUND)
  594. Object_Redraw main_handle,s_background
  595. tree&=oldtree&
  596. END SUB
  597.  
  598. '··············································································
  599.  
  600. SUB DISPLAY_PRINTERDRIVER2
  601. STATIC i,k
  602.  
  603. k=0
  604. Sette_ptext_update O1,OPTIONS$(k+0),1
  605. Sette_ptext_update O2,OPTIONS$(k+1),1
  606. Sette_ptext_update O3,OPTIONS$(k+2),1
  607. Sette_ptext_update O4,OPTIONS$(k+3),1
  608. Sette_ptext_update O5,OPTIONS$(k+4),1
  609. Sette_ptext_update O6,OPTIONS$(k+5),1
  610. Sette_ptext_update O7,OPTIONS$(k+6),1
  611. Sette_ptext_update O8,OPTIONS$(k+7),1
  612. Sette_ptext_update O9,OPTIONS$(k+8),1
  613. Sette_ptext_update O10,OPTIONS$(k+9),1
  614. Sette_ptext_update O11,OPTIONS$(k+10),1
  615. Sette_ptext_update O12,OPTIONS$(k+11),1
  616.  
  617. Sette_ptext_update C1,CCODES$(k+0),1
  618. Sette_ptext_update C2,CCODES$(k+1),1
  619. Sette_ptext_update C3,CCODES$(k+2),1
  620. Sette_ptext_update C4,CCODES$(k+3),1
  621. Sette_ptext_update C5,CCODES$(k+4),1
  622. Sette_ptext_update C6,CCODES$(k+5),1
  623. Sette_ptext_update C7,CCODES$(k+6),1
  624. Sette_ptext_update C8,CCODES$(k+7),1
  625. Sette_ptext_update C9,CCODES$(k+8),1
  626. Sette_ptext_update C10,CCODES$(k+9),1
  627. Sette_ptext_update C11,CCODES$(k+10),1
  628. Sette_ptext_update C12,CCODES$(k+11),1
  629.  
  630. k=0
  631. FOR i=SO1 TO SO12
  632.     Sette_ptext_update i,OPTIONS$(k),2
  633.     INCR k
  634. NEXT
  635. END SUB
  636.  
  637. '··············································································
  638.  
  639. SUB UPDATE_EDITDISPLAY
  640. SHARED total_edititems,top_edititem
  641. SHARED edit_handle
  642. STATIC i,k
  643.  
  644. k=top_edititem
  645. Sette_ptext_update O1,OPTIONS$(k+0),1
  646. Sette_ptext_update O2,OPTIONS$(k+1),1
  647. Sette_ptext_update O3,OPTIONS$(k+2),1
  648. Sette_ptext_update O4,OPTIONS$(k+3),1
  649. Sette_ptext_update O5,OPTIONS$(k+4),1
  650. Sette_ptext_update O6,OPTIONS$(k+5),1
  651. Sette_ptext_update O7,OPTIONS$(k+6),1
  652. Sette_ptext_update O8,OPTIONS$(k+7),1
  653. Sette_ptext_update O9,OPTIONS$(k+8),1
  654. Sette_ptext_update O10,OPTIONS$(k+9),1
  655. Sette_ptext_update O11,OPTIONS$(k+10),1
  656. Sette_ptext_update O12,OPTIONS$(k+11),1
  657.  
  658. Sette_ptext_update C1,CCODES$(k+0),1
  659. Sette_ptext_update C2,CCODES$(k+1),1
  660. Sette_ptext_update C3,CCODES$(k+2),1
  661. Sette_ptext_update C4,CCODES$(k+3),1
  662. Sette_ptext_update C5,CCODES$(k+4),1
  663. Sette_ptext_update C6,CCODES$(k+5),1
  664. Sette_ptext_update C7,CCODES$(k+6),1
  665. Sette_ptext_update C8,CCODES$(k+7),1
  666. Sette_ptext_update C9,CCODES$(k+8),1
  667. Sette_ptext_update C10,CCODES$(k+9),1
  668. Sette_ptext_update C11,CCODES$(k+10),1
  669. Sette_ptext_update C12,CCODES$(k+11),1
  670. CALL SCROLL(total_edititems,12,top_edititem,E_SLIDER,E_BACKGROUND,edit_handle)
  671. Object_Redraw edit_handle,E_BACKDROP
  672. END SUB
  673.  
  674. '··············································································
  675.  
  676. SUB UPDATE_MAINDISPLAY
  677. SHARED total_mainitems,top_mainitem
  678. SHARED main_handle
  679. STATIC i,k
  680.  
  681. k=top_mainitem
  682. FOR i=SO1 TO SO12
  683.     Sette_ptext_update i,OPTIONS$(k),2
  684.     INCR k
  685. NEXT
  686. CALL SCROLL(total_mainitems,12,top_mainitem,S_SLIDER,S_BACKGROUND,main_handle)
  687. Object_Redraw main_handle,S_BACKDROP
  688. END SUB
  689.  
  690. '··············································································
  691.  
  692. SUB UPDATE_BATCHDISPLAY
  693. SHARED total_batchitems,top_batchitem
  694. SHARED main_handle
  695. STATIC i,k
  696.  
  697. k=top_batchitem
  698. FOR i=B1 TO B10
  699.     Sette_ptext_update i,BOPTIONS$(k),2
  700.     INCR k
  701.     IF k>total_batchitems THEN EXIT FOR
  702. NEXT
  703. CALL SCROLL(total_batchitems,10,top_batchitem,B_SLIDER,B_BACKGROUND,main_handle)
  704. Object_Redraw main_handle,B_BACKDROP
  705. END SUB
  706.  
  707. '··············································································
  708.  
  709. SUB Send_to_Output(command,object)
  710. SHARED Output$,total_batchitems
  711.  
  712. MOUSE 2
  713. SELECT CASE Output$
  714.     CASE="Direct"
  715.         IF ccodes$(command)="" THEN EXIT SELECT
  716.         CALL Printer_Status(object)
  717.         CALL Send_Command(ccodes$(command))
  718.     CASE="To Batch"
  719.         IF ccodes$(command)="" THEN EXIT SELECT
  720.         REDIM PRESERVE BOPTIONS$(total_batchitems+1)
  721.         REDIM PRESERVE BCCODES$(total_batchitems+1)
  722.         BOPTIONS$(total_batchitems)=OPTIONS$(command)
  723.         BCCODES$(total_batchitems)=CCODES$(command)
  724.         INCR total_batchitems
  725.         CALL UPDATE_BATCHDISPLAY
  726. END SELECT
  727. MOUSE 0
  728. END SUB
  729.  
  730. '··············································································
  731.  
  732. ' Check printer is ready to receive data
  733. SUB Printer_Status(object)
  734. SHARED main_handle
  735. STATIC time!,button
  736.  
  737. MOUSE 2
  738. ' Is the printer ready to receive data
  739. IF bcostat(0)=0 THEN
  740.     time!=TIMER
  741.     DO
  742.         IF INKEY$=CHR$(27) THEN EXIT SUB
  743.     LOOP UNTIL TIMER-time!>2
  744.     button=form_alert(1,"[1][  Please turn your printer |  ON LINE! ][ Try Again | Cancel ]")
  745.     SELECT CASE button
  746.         CASE 1
  747.             CALL Printer_Status(object)
  748.         CASE 2
  749.             IF NOT object=-1 THEN Setob_state object,0:Object_Redraw main_handle,object
  750.             MOUSE 0
  751.             GOTO Main_Loop
  752.     END SELECT
  753. END IF
  754. MOUSE 0
  755. END SUB
  756.  
  757. '··············································································
  758.  
  759. SUB Send_Command(Code$)
  760. STATIC i,original$
  761.  
  762. original$=code$
  763. DO
  764.     i=0
  765.     DO
  766.         INCR i
  767.         IF MID$(Code$,i,1)="," THEN EXIT LOOP
  768.         IF i>LEN(Code$) THEN EXIT LOOP
  769.     LOOP 
  770.     OUT 0,VAL(LEFT$(Code$,i-1))
  771.     IF i+1>LEN(Code$) THEN EXIT LOOP
  772.     Code$=RIGHT$(Code$,LEN(Code$)-i)
  773. LOOP
  774. code$=original$
  775. END SUB
  776.  
  777. '··············································································
  778.  
  779. SUB QUIT_ME
  780. SHARED finished_flag,commonclose
  781. STATIC button
  782.  
  783. MOUSE 2
  784. button=form_alert(2,"[2][  Do you really want to quit ? |  All unsaved data will be |  lost! ][ Continue | Cancel ]")
  785. SELECT CASE button
  786.     CASE 1
  787.         commonclose=-1
  788.         finished_flag=-1
  789. END SELECT
  790. MOUSE 0
  791. END SUB
  792.  
  793. '··············································································
  794.  
  795. ON ERROR GOTO ERROR_HANDLER
  796. startprogram CURDIR$+"\PRINT_IT.RSC",Menu,-1
  797. CALL INITIALISE
  798. Main_Loop:
  799. xHGTloop2
  800. stopProgram
  801.  
  802. '··············································································
  803.  
  804. 'The New Toolbox's main loop
  805. SUB xHGTloop2
  806. STATIC ev,key_pressed,clicks,x,y,kstate,button
  807. STATIC mclicks,mmask,mstate,data_changed,time!
  808. SHARED finished_flag,Mess(1),clicks_enabled,keys_enabled,menus_enabled,forms_enabled
  809.  REDIM mess(7)
  810. SHARED mouse_detect_both
  811. IF mouse_detect_both THEN
  812.     mclicks=258
  813.     mmask=3
  814.     mstate=0
  815. ELSE
  816.     mclicks=2
  817.     mmask=1
  818.     mstate=1
  819. END IF    
  820.  
  821.  finished_flag=0
  822.  data_changed=-1
  823.  DO
  824.     junk=wind_update(END_UPDATE)
  825.     ev=evnt_multi(MU_MESAG+MU_KEYBD+MU_BUTTON+MU_TIMER,mclicks,mmask,mstate, _
  826.             0,0,0,0,0,_
  827.             0,0,0,0,0,_
  828.             VARPTR(mess(0)),250,_
  829.             x,y, _
  830.             button,kstate, _
  831.             key_pressed,clicks)
  832.     junk=wind_update(BEG_UPDATE)
  833.  
  834.     IF data_changed=0 THEN IF TIMER-time!<1 THEN data_changed=-1:CALL GET_DATA
  835.  
  836.     IF ev AND MU_KEYBD THEN    
  837.         KeyboardEvent key_pressed,kstate
  838.         IF (key_pressed AND 255)=<13 THEN
  839.             IF (key_pressed AND 255)=8 THEN
  840.                 time!=TIMER
  841.                 data_changed=0
  842.             END IF
  843.         ELSE
  844.             time!=TIMER
  845.             data_changed=0
  846.         END IF
  847.     END IF
  848.  
  849.     IF ev AND MU_MESAG THEN
  850.         do_message
  851.     END IF
  852.     IF ev AND MU_BUTTON THEN
  853.         IF forms_enabled THEN
  854.             IF NOT ProcessFormClicks(button,clicks,kstate,x,y) THEN
  855.                 IF clicks_enabled THEN     ProcessClicks clicks,kstate,x,y
  856.             END IF
  857.         ELSE
  858.             IF clicks_enabled THEN     ProcessClicks clicks,kstate,x,y
  859.         END IF
  860.     END IF
  861.     IF finished_flag=-1 THEN EXIT LOOP
  862.  LOOP UNTIL INKEY$=CHR$(27)
  863. END SUB
  864.  
  865. '··············································································
  866.  
  867. ' If an error has occurred...
  868. ERROR_HANDLER:
  869. ' Display alert and abort to main loop
  870. ' Quit
  871. IF ERR=68 THEN 
  872.     CALL NoMoreWindows:SYSTEM
  873. ELSE
  874.     button=form_alert(1,"[1][  An ERROR"+STR$(ERR)+" has occurred ! |  Please contact Cadenza |  Software with Error No.  |  and symptoms. ][ Abort ]")
  875.     junk=rsrc_free
  876.     SYSTEM
  877. END IF
  878.  
  879. '··············································································
  880.  
  881. SUB LOAD_BATCH
  882. SHARED total_batchitems,top_batchitem
  883. SHARED FileSelect$,fsname$,fspath$
  884. STATIC i,check,current_option$
  885.  
  886. ' Call FileSelector
  887. MOUSE 2
  888. CALL FileSelect$(CURDIR$+"\*.BAT",fsname$,"Batch File...")
  889. MOUSE 0
  890.  
  891. MOUSE 2
  892. IF fsname$<>"" THEN
  893.     IF FileSelect$<>"" THEN
  894.     IF FEXISTS(FileSelect$) THEN
  895.         OPEN FileSelect$ FOR INPUT AS #1
  896.         i=0
  897.         check=-1
  898.         DO
  899.             REDIM PRESERVE BOPTIONS$(i)
  900.             REDIM PRESERVE BCCODES$(i)
  901.             INPUT #1,BOPTIONS$(i),BCCODES$(i)
  902.  
  903.             IF check=-1 THEN
  904.                 IF BOPTIONS$(0)="·Print IT Batch File·" THEN
  905.                     IF NOT BCCODES$(0)="·© 1996 Cadenza Software - Written by Matthew Bacon·" THEN
  906.                         junk=form_alert(1,"[1][  This is not a valid |  Print IT Batch File. | ][ Abort ]")
  907.                         i=0
  908.                         EXIT LOOP
  909.                     END IF
  910.                 ELSE
  911.                     junk=form_alert(1,"[1][  This is not a valid |  Print IT Batch File. | ][ Abort ]")
  912.                     i=0
  913.                     EXIT LOOP
  914.                 END IF
  915.                 check=0
  916.             END IF
  917.  
  918.             IF BOPTIONS$(i)="" AND BCCODES$(i)="" THEN 
  919.  
  920.             ELSE
  921.             current_option$=BOPTIONS$(i)
  922.             SELECT CASE current_option$
  923.                 CASE="·Start·"
  924.                     i=0
  925.                 CASE="·End·"
  926.                     BOPTIONS$(i)=""
  927.                     BCCODES$(i)=""
  928.                     EXIT LOOP
  929.                 CASE ELSE
  930.                     INCR i
  931.             END SELECT
  932.             END IF
  933.         LOOP UNTIL EOF(1)
  934.         CLOSE #1
  935.         total_batchitems=i
  936.         top_batchitem=0
  937.     ELSE
  938.         ' If the filename passed does not exists then display error
  939.         junk=form_alert(1,"[1][  Error while loading Driver |  file into memory. | ][ Abort ]")
  940.     END IF
  941.     END IF
  942. END IF
  943. MOUSE 0
  944. END SUB
  945.  
  946. '··············································································
  947.  
  948. ' Save a text file from memory to disk
  949. SUB SAVE_BATCH
  950. SHARED total_batchitems
  951. SHARED FileSelect$,fsname$,fspath$
  952. STATIC i
  953.  
  954. ' Call FileSelector
  955. MOUSE 2
  956. CALL FileSelect$(CURDIR$+"\*.BAT",fsname$,"Save Batch...")
  957. MOUSE 0
  958.  
  959. MOUSE 2
  960. IF fsname$<>"" THEN
  961. IF FileSelect$<>"" THEN
  962.     ' Open file to channel 1
  963.     OPEN FileSelect$ FOR OUTPUT AS #1
  964.     WRITE #1,"·Print IT Batch File·","·© 1996 Cadenza Software - Written by Matthew Bacon·"
  965.     WRITE #1,"",""
  966.     WRITE #1,"·Start·",""
  967.  
  968.     FOR i=0 TO total_batchitems-1
  969.         WRITE #1,BOPTIONS$(i),BCCODES$(i)
  970.     NEXT
  971.  
  972.     WRITE #1,"·End·",""
  973.     CLOSE #1
  974.     junk=form_alert(1,"[0][  Batch File has been saved |  to disk. | ][ OK ]")
  975. END IF
  976. END IF
  977. MOUSE 0
  978. END SUB
  979.  
  980. '··············································································
  981.  
  982. SUB DISPLAY_BATCH
  983. SHARED total_batchitems,main_handle
  984. STATIC i,k,oldtree&
  985.  
  986. oldtree&=tree&
  987. SelectTree FORM_MAIN
  988. k=0
  989. SELECT CASE total_batchitems
  990.     CASE 0
  991.         FOR i=B1 TO B10
  992.             Sette_ptext_update i,"",2
  993.         NEXT
  994.     CASE ELSE
  995.         FOR i=B1 TO B10
  996.             IF k>total_batchitems THEN
  997.                 Sette_ptext_update i,"",2
  998.             ELSE
  999.                 Sette_ptext_update i,BOPTIONS$(k),2
  1000.             END IF
  1001.             INCR k
  1002.         NEXT
  1003. END SELECT
  1004. Object_Redraw main_handle,B_BACKDROP
  1005. CALL SCROLL2(total_batchitems,10,B_SLIDER,B_BACKGROUND)
  1006. Object_Redraw main_handle,b_background
  1007. tree&=oldtree&
  1008. END SUB
  1009.  
  1010. '··············································································
  1011.  
  1012. SUB SEND_BATCH(object)
  1013. SHARED total_batchitems
  1014. STATIC i
  1015.  
  1016. MOUSE 2
  1017. FOR i=0 TO (total_batchitems-1)
  1018.     IF BCCODES$(i)<>"" THEN 
  1019.         CALL Printer_Status(object)
  1020.         CALL Send_Command(BCCODES$(i))
  1021.     END IF
  1022. NEXT
  1023. MOUSE 0
  1024. END SUB
  1025.  
  1026. '··············································································
  1027.  
  1028. SUB Delete_Batch(Object)
  1029. SHARED total_batchitems,top_batchitem
  1030. STATIC i
  1031.  
  1032. FOR i=object TO total_batchitems-1
  1033.     IF i>=total_batchitems THEN EXIT SUB
  1034.     BOPTIONS$(i)=BOPTIONS$(i+1)
  1035.     BCCODES$(i)=BCCODES$(i+1)
  1036. NEXT
  1037.  
  1038. BOPTIONS$(total_batchitems)=""
  1039. BCCODES$(total_batchitems)=""
  1040.  
  1041. DECR total_batchitems
  1042. IF total_batchitems=<10 THEN top_batchitem=0
  1043. CALL UPDATE_BATCHDISPLAY
  1044. END SUB
  1045.  
  1046. '··············································································
  1047.